package cn.wolfcode.trip.admin.controller;

import cn.wolfcode.trip.base.domain.TravelAllSee;
import cn.wolfcode.trip.base.query.StrategyQueryObject;
import cn.wolfcode.trip.base.service.IStrategyService;
import cn.wolfcode.trip.base.service.ITravelAllSeeService;
import cn.wolfcode.trip.base.util.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/travelAllSee")
public class TravelAllSeeController {
    @Autowired
    private ITravelAllSeeService travelAllSeeService;
    @Autowired
    private IStrategyService strategyService;

    @RequestMapping("/list")
    public String list(@ModelAttribute("qo") StrategyQueryObject qo, Model model) {
        model.addAttribute("strategies" , strategyService.list());
        model.addAttribute("pageInfo",travelAllSeeService.query(qo));
        return "travelAllSee/list";
    }

    @RequestMapping("/saveOrUpdate")
    @ResponseBody
    public Object saveOrUpdate(TravelAllSee entity) {
        JSONResult result = new JSONResult();
        try {
            travelAllSeeService.saveOrUpdate(entity);
        } catch (Exception e) {
            result.mark(e.getMessage());
        }
        return result;
    }

}
